<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <link rel="stylesheet" href="http://cdn.staticfile.org/cesium/1.69.0/Widgets/widgets.css">
    <link rel="stylesheet" href="../css//index.css">
</head>

<body>
    <div class="fun-menu">
        挖洞类
        <button onclick="measureAndDraw()">岩层</button>
        <button onclick="clear1()">清除</button>
    </div>
    <div id=cesiumContainer></div>

    <script src="http://cdn.staticfile.org/cesium/1.69.0/Cesium.js"></script>

    <script src="../libs/cpc/index.js"></script>
    <script>
        const map = new cpc.Map({
            container: "cesiumContainer",
                baseMaps: [
                    {
                        type: "TDTImageryLayer",
                        mold: "image",
                        tk: "7b435c61bff7f77eb49206e10d6397bd",
                    },
                ],
                camera: {
                    position: {
                        x: 119.4135823,
                        y: 26.11072,
                        z: 1069,
                    },
                    angle: {
                        heading: 0,
                        pitch: -90,
                        roll: 0,
                    },
                },
        });

        function measureAndDraw() {
            map.drawManager
                .activate(cpc.EDrawManager.DrawPolygon)
                .then((res) => {
                    map.drawManager.deactivate();
                    console.log("结果", res);
                    const option = {
                        excavateDepth: 200,
                        bottomImage: "../images/excavate/excavate_bottom_min.jpg",
                        sideImage: "../images/excavate/excavate_kuangqu.jpg"
                    }
                    //凸多边形有效
                    map.holeManager.holeStratum.start(res.data.positions, option);
                })
                .catch((error) => {
                    console.error("结束", error);
                });
        }
        function clear1() {
            map.holeManager.holeStratum.stop();
        }
    </script>
</body>

</html>